home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 26.zip / BS1 part 26 / Aztec C v5.2a disk 4.adf / 204inc_i.lzh / intuition / sghooks.i < prev   
Text File  |  1991-03-14  |  7KB  |  217 lines

  1.     IFND INTUITION_SGHOOKS_I
  2. INTUITION_SGHOOKS_I SET 1
  3. **
  4. ** $Filename: intuition/sghooks.i $
  5. ** $Release: 2.04 $
  6. ** $Revision: 36.4 $
  7. ** $Date: 91/02/12 $
  8. **
  9. **  String gadget extensions and hooks
  10. **
  11. **  (C) Copyright 1985,1986,1987,1988,1989,1990 Commodore-Amiga, Inc.
  12. **        All Rights Reserved
  13. **
  14.  
  15.     IFND EXEC_TYPES_I
  16.     INCLUDE "exec/types.i"
  17.     ENDC
  18.  
  19.  STRUCTURE StringExtend,0
  20.     ; display specifications
  21.     APTR    sex_Font    ; must be an open Font (not TextAttr)
  22.     STRUCT    sex_Pens,2    ; color of text/background
  23.     STRUCT    sex_ActivePens,2 ; colors when gadget is active
  24.  
  25.     ; edit specifications
  26.     ULONG    sex_InitialModes ; initial mode flags, below
  27.     APTR    sex_EditHook    ; if non-NULL, must supply WorkBuffer
  28.     APTR    sex_WorkBuffer    ; must be as large as StringInfo.Buffer
  29.  
  30.     STRUCT    sex_Reserved,16    ; set to 0
  31.  LABEL    sex_SIZEOF
  32.  
  33.  
  34.  STRUCTURE SGWork,0
  35.     ; set up when gadget is first activated
  36.     APTR        sgw_Gadget    ; the contestant itself
  37.     APTR        sgw_StringInfo    ; easy access to sinfo
  38.     APTR        sgw_WorkBuffer    ; intuition's planned result
  39.     APTR        sgw_PrevBuffer    ; what was there before
  40.     ULONG        sgw_Modes    ; current mode
  41.  
  42.     ; modified for each input event
  43.     APTR        sgw_IEvent    ; actual event: do not change
  44.     UWORD        sgw_Code    ; character code, if one byte
  45.     WORD        sgw_BufferPos    ; cursor position
  46.     WORD        sgw_NumChars
  47.     ULONG        sgw_Actions    ; what Intuition will do
  48.     LONG        sgw_LongInt    ; temp storage for longint
  49.  
  50.     APTR        sgw_GadgetInfo    ; see cghooks.h
  51.     UWORD        sgw_EditOp    ; from constants below
  52.  LABEL    sgw_SIZEOF    ; this may change as the structure is extended
  53.  
  54.  
  55. * SGWork.EditOp -
  56. * These values indicate what basic type of operation the global
  57. * editing hook has performed on the string before your gadget's custom
  58. * editing hook gets called.  You do not have to be concerned with the
  59. * value your custom hook leaves in the sgw_EditOp field, only if you
  60. * write a global editing hook.
  61. *
  62. * For most of these general edit operations, you'll want to compare
  63. * the BufferPos and NumChars of the StringInfo (before global editing)
  64. * and SGWork (after global editing).
  65.  
  66. EO_NOOP        EQU ($0001)
  67.     ; did nothing
  68. EO_DELBACKWARD    EQU ($0002)
  69.     ; deleted some chars (maybe 0).
  70. EO_DELFORWARD    EQU ($0003)
  71.     ; deleted some characters under and in front of the cursor
  72. EO_MOVECURSOR    EQU ($0004)
  73.     ; moved the cursor
  74. EO_ENTER    EQU ($0005)
  75.         ; "enter" or "return" key, terminate
  76. EO_RESET    EQU ($0006)
  77.     ; current Intuition-style undo    
  78. EO_REPLACECHAR    EQU ($0007)
  79.     ; replaced one character and (maybe) advanced cursor
  80. EO_INSERTCHAR    EQU ($0008)
  81.     ; inserted one char into string or added one at end
  82. EO_BADFORMAT    EQU ($0009)
  83.     ; didn't like the text data, e.g., Bad LONGINT
  84. EO_BIGCHANGE    EQU ($000A)    ; unused by Intuition
  85.     ; complete or major change to the text, e.g. new string
  86. EO_UNDO        EQU ($000B)    ; unused by Intuition
  87.     ; some other style of undo
  88. EO_CLEAR    EQU ($000C)
  89.     ; clear the string
  90. EO_SPECIAL    EQU ($000D)    ; unused by Intuition
  91.     ; some operation that doesn't fit into the categories here
  92.  
  93.  
  94. ; Mode Flags definitions (ONLY first group allowed as InitialModes)
  95.  
  96. SGM_REPLACE    EQU    1
  97. SGMB_REPLACE    EQU    0
  98. SGMF_REPLACE    EQU    1
  99. ; please initialize StringInfo with in-range value of BufferPos 
  100. ; if you are using SGM_REPLACE mode.
  101.  
  102. ; fixed length buffer, always set SGM_REPLACE, too.
  103. SGM_FIXEDFIELD    EQU $00000002
  104. SGMB_FIXEDFIELD    EQU 1
  105. SGMF_FIXEDFIELD    EQU 2
  106.  
  107. ; don't filter control chars
  108. SGM_NOFILTER    EQU $00000004
  109. SGMB_NOFILTER    EQU 2
  110. SGMF_NOFILTER    EQU 4
  111.  
  112. ; SGM_EXITHELP is new for V37, and ignored by V36:
  113. ; exit with code = 0x5F if HELP hit
  114. SGM_EXITHELP    EQU $00000080
  115. SGMB_EXITHELP    EQU 7
  116. SGMF_EXITHELP    EQU $80
  117.  
  118.  
  119. ; String Gadget Action Flags (put in SGWork.Actions by EditHook)
  120. SGA_USE        EQU $1        ; use contents of SGWork
  121. SGAB_USE    EQU 0
  122. SGAF_USE    EQU $1
  123.  
  124. SGA_END        EQU $2        ; terminate gadget, code in Code field
  125. SGAB_END    EQU 1
  126. SGAF_END    EQU $2
  127.  
  128. SGA_BEEP    EQU $4        ; flash the screen for the user
  129. SGAB_BEEP    EQU 2
  130. SGAF_BEEP    EQU $4
  131.  
  132. SGA_REUSE    EQU $8        ; reuse input event
  133. SGAB_REUSE    EQU 3
  134. SGAF_REUSE    EQU $8
  135.  
  136. SGA_REDISPLAY    EQU $10        ; gadget visuals changed
  137. SGAB_REDISPLAY        EQU 4
  138. SGAF_REDISPLAY        EQU $10
  139.  
  140. ; New for V37:
  141. SGA_NEXTACTIVE    EQU $20        ; Make next possible gadget active.
  142. SGAB_NEXTACTIVE    EQU 5
  143. SGAF_NEXTACTIVE    EQU $20
  144.  
  145. ; New for V37:
  146. SGA_PREVACTIVE    EQU $40        ; Make previous possible gadget active.
  147. SGAB_PREVACTIVE    EQU 6
  148. SGAF_PREVACTIVE    EQU $40
  149.  
  150.  
  151. ; function id for only existing custom string gadget edit hook
  152. SGH_KEY        EQU    1    ; process editing keystroke
  153. SGH_CLICK    EQU    2    ; process mouse click cursor position
  154.  
  155. * Here's a brief summary of how the custom string gadget edit hook works:
  156. *    You provide a hook in StringInfo.Extension.EditHook.
  157. *    The hook is called in the standard way with the 'object'
  158. *    a pointer to SGWork, and the 'message' a pointer to a command
  159. *    block, starting either with (longword) SGH_KEY, SGH_CLICK,
  160. *    or something new.
  161. *
  162. *    You return 0 if you don't understand the command (SGH_KEY is
  163. *    required and assumed).    Return non-zero if you implement the
  164. *    command.
  165. *
  166. *   SGH_KEY:
  167. *    There are no parameters following the command longword.
  168. *
  169. *    Intuition will put its idea of proper values in the SGWork
  170. *    before calling you, and if you leave SGA_USE set in the
  171. *    SGWork.Actions field, Intuition will use the values
  172. *    found in SGWork fields WorkBuffer, NumChars, BufferPos,
  173. *    and LongInt, copying the WorkBuffer back to the StringInfo
  174. *    Buffer.
  175. *
  176. *    NOTE WELL: You may NOT change other SGWork fields.
  177. *
  178. *    If you clear SGA_USE, the string gadget will be unchanged.
  179. *
  180. *    If you set SGA_END, Intuition will terminate the activation
  181. *    of the string gadget.  If you also set SGA_REUSE, Intuition
  182. *    will reuse the input event after it deactivates your gadget.
  183. *
  184. *    In this case, Intuition will put the value found in SGWork.Code
  185. *    into the IntuiMessage.Code field of the IDCMP_GADGETUP message it
  186. *    sends to the application.
  187. *
  188. *    If you set SGA_BEEP, Intuition will call DisplayBeep(); use
  189. *    this if the user has typed in error, or buffer is full.
  190. *
  191. *    Set SGA_REDISPLAY if the changes to the gadget warrant a
  192. *    gadget redisplay.  Note: cursor movement requires a redisplay.
  193. *
  194. *    Starting in V37, you may set SGA_PREVACTIVE or SGA_NEXTACTIVE
  195. *    when you set SGA_END.  This tells Intuition that you want
  196. *    the next or previous gadget with GFLG_TABCYCLE to be activated.
  197. *
  198. *   SGH_CLICK:
  199. *    This hook command is called when Intuition wants to position
  200. *    the cursor in response to a mouse click in the string gadget.
  201. *
  202. *    Again, here are no parameters following the command longword.
  203. *
  204. *    This time, Intuition has already calculated the mouse position
  205. *    character cell and put it in SGWork.BufferPos.    The previous
  206. *    BufferPos value remains in the SGWork.StringInfo.BufferPos.
  207. *
  208. *    Intuition will again use the SGWork fields listed above for
  209. *    SGH_KEY.  One restriction is that you are NOT allowed to set
  210. *    SGA_END or SGA_REUSE for this command.    Intuition will not
  211. *    stand for a gadget which goes inactive when you click in it.
  212. *
  213. *    You should always leave the SGA_REDISPLAY flag set, since Intuition
  214. *    uses this processing when activating a string gadget.
  215.  
  216.     ENDC
  217.